<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
    testRunner.setPopupBlockingEnabled(false);
}

function log(msg) {
    var div = document.createElement("div");
    div.appendChild(document.createTextNode(msg));
    document.getElementById("console").appendChild(div);
}

window.onload = function() {
    window.popup = window.open("resources/popup-ready-to-navigate-child.html", "target");
}

window.addEventListener("message", function(e) {
    log(e.data);

    if (e.data == "ready") {
        window.savedFunction = popup.go;
        popup.location = "http://127.0.0.1:8080/security/frameNavigation/resources/iframe-with-inner-frame-on-foreign-domain.html";
        return;
    }

    if (e.data = "iframe-with-inner-frame-on-foreign-domain-LOADED") {
        log("Attempting navigation...");
        window.savedFunction();
        setTimeout(function() {
            // Unfortunately, there's no way to receive positive confirmation
            // that the navigation failed, so we just complete the test
            // asynchronously.
            if (window.testRunner)
                testRunner.notifyDone();
        }, 0);
        return;
    }

}, false);
</script>
</head>
<body>
This test passes if it doesn't alert "FAIL".
<div id="console"></div>
</body>
</html>
